剛剛有人問我說如何讓 coverage 可以達到 90% 以上
老實說, 我沒有好的做法
基本上我覺得你做到 8x% 已經很強了
最多看看你沒 coverage 到的地方, 是否能再加開 case? 再加開的 ROI 是否值得? 如果不測發生問題後的代價有多高?
而且就算做到 100% 也不代表品質沒問題
說不定花些時間 review 那些 test case
或是開些 end 2 end 的 case 會比較有意義些
當然啦, 這是你老闆的定的目標
好像也只能照做
下面有幾篇不錯的資料可以參考
(1) What is a reasonable code coverage % for unit tests (and why)?
https://stackoverflow.com/questions/90002/what-is-a-reasonable-code-coverage-for-unit-tests-and-why
(2) How much Code Coverage is “enough”?
https://softwareengineering.stackexchange.com/questions/1380/how-much-code-coverage-is-enough
(3) Code Coverage Best Practices
https://testing.googleblog.com/2020/08/code-coverage-best-practices.html